package com.jishaokang.service.impl;

import com.google.gson.Gson;
import com.jishaokang.base.Result;
import com.jishaokang.cache.ResultCache;
import com.jishaokang.dao.ForbidUserDAO;
import com.jishaokang.dao.UserDAO;
import com.jishaokang.model.dto.ForbidUser;
import com.jishaokang.model.dto.PowerClass;
import com.jishaokang.model.dto.User;
import com.jishaokang.service.ForbidUserService;
import com.jishaokang.util.ForbidUtil;
import com.jishaokang.util.MessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by NANA_Final on 2019/6/21.
 */
@Service
public class ForbidUserServiceImpl implements ForbidUserService {

    @Autowired
    private ForbidUserDAO forbidUserDAO;
    @Autowired
    private ForbidUtil forbidUtil;
    @Autowired
    private MessageUtil messageUtil;

    @Override
    public Result addForbidUser(ForbidUser forbidUser) {
        forbidUtil.forbidUserPower(forbidUser.getUserId(),forbidUser.getForbidUserType());
        forbidUserDAO.insert(forbidUser);
        messageUtil.sendSystemMessage("您已被封禁部分权限",forbidUser.getUserId());
        return ResultCache.OK;
    }

    @Override
    public Result selectForbidUserByUserId(ForbidUser forbidUser) {
        List<ForbidUser> forbidUsers = forbidUserDAO.selectByUserId(forbidUser);
        return ResultCache.getDataOk(forbidUsers);
    }

}